package com.tencent.wxcloudrun.service.impl;


import com.tencent.wxcloudrun.dao.CountersMapper;
import com.tencent.wxcloudrun.dao.RwtfMapper;
import com.tencent.wxcloudrun.model.Rwtf;
import com.tencent.wxcloudrun.service.RwtfService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;

import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @author 小懒虫
 * @date 2024/12/01
 */
@Service
@Slf4j
public class RwtfServiceImpl implements RwtfService {

    final RwtfMapper rwtfMapper;

    public RwtfServiceImpl(@Autowired RwtfMapper rwtfMapper) {
        this.rwtfMapper = rwtfMapper;
    }

    public Rwtf rand(){
        return rwtfMapper.rand();
    }

    @Override
    public Rwtf randRwtfCache() {
        // 缓存为空，尝试从数据库获取数据
        return rand();
    }

    @Override
    public int getCacheCount() {
        // 获取总任务量

        return rwtfMapper.count();
    }

    @Override
    public Rwtf randRwtfCacheNoRepeat(String linkAddress) {
        // 获取不是linkAddress的一条随机任务
        return rwtfMapper.randRwtfCacheNoRepeat(linkAddress);
    }


}